import React, { Component } from 'react';
import { Modal, Form, Input,Select,DatePicker,Popconfirm ,Row,Col,Button,Icon,Upload, message} from 'antd';
import styles from '../item.less';
import moment from 'moment'
const FormItem = Form.Item;

const Option = Select.Option;
const Search = Input.Search;


function handleChange(value) {
  console.log(`selected ${value}`);
}

class _Filter extends Component {
    constructor(props) {
      super(props);

      this.state = {

      };
    }
    handleChange(key,value){
        console.log('filter changed',{key,value})
        var fd = Object.assign({},this.props.filter)
        if(key==='product_num'){
           fd=Object.assign(fd,{"products":{"$elemMatch":{"product_num":value}}})
        }else if(key==='stock_num'){
           fd=Object.assign(fd,{"products":{"$elemMatch":{"stock_num":value}}})
        }else{
          fd[key]= value ==''?null : value
        }
        this.props.filterCallback(fd)
    }
    render() {
        return (<div>
            <Search
              placeholder="搜索品牌"
              style={{ width: 200 }}
              onSearch={v => this.handleChange('brand_num',v)}
            />
            <Search
              placeholder="产品编号"
              style={{ width: 200 }}
              onSearch={v => this.handleChange('product_num',v)}
            />
            <Search
              placeholder="现货编号"
              style={{ width: 200 }}
              onSearch={v => this.handleChange('stock_num',v)}
            />
        </div>)
    }
}

export default Form.create()(_Filter);
